<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>基地活动列表</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

    <!-- 可选的Bootstrap主题文件（一般不用引入） -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

    <link rel="stylesheet" href="/css/font-awesome.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" href="/css/djs.css">

    <script src="/js/user.js"></script>
    <script type="text/javascript" src="/js/base.js"></script>
</head>
<body>
<div id="top">

</div>
<div class="container">
    <div id="asideAffix" class="aside" data-spy="affix">
    </div>
    <div class="content" style="margin-top: 0;">
        <div class="page-volunteer-recruitment-grid" style="padding:0; width:100%;">
            <div class="page-searchbox">
                <input type="text" placeholder="输入查询条件">

                <div class="pull-right" style="width: 260px;">
                    <button class="btn btn-primary" id="search"
                            style="border-color: #ffd632;background: #ffd632 linear-gradient(to bottom,#ffd632 0,#ffd632 100%);text-align: center;width: 121px;height: 46px;">
                        查询
                    </button>
                </div>
            </div>
            <table id="activityList" class="table table-bordered table-hover table-striped " style="margin-top: 0;">
                <tr class='trh'>
                    <td>活动编码</td>
                    <td>活动名称</td>
                    <td>参与人数</td>
                    <td>公益时间</td>
                </tr>
            </table>
        </div>
    </div>
</div>
</body>

<script type="text/javascript">

    var statusStr = function (data) {
        if (data == 10) {
            return "解冻";
        }
        return "冻结";
    };

    var statusStrUn = function (data) {
        if (data == 10) {
            return "冻结";
        }
        return "解冻";
    };

    var listStr = function (data) {
        return "<tr><td  style='color: #425c75;cursor:pointer;' onclick='groupInfo(" + data.id + ")'>" + data.activityCode + "</td><td>" + data.name + "</td><td  style='color: #425c75;cursor:pointer;' onclick='ActivityInfo(" + data.id + ")'>" + data.attends + "</td><td  style='color: #425c75;cursor:pointer;' onclick='ActivityInfo(" + data.id + ")'>" + data.times + "</td></tr>";
    };

    function groupInfo(activityId) {
        location.href = "/html/group/groupActivityInfo.html?activityId=" + activityId + "&groupId="+location.search.substr(1).split("=")[1];
    }

    function ActivityInfo(activityId){
        location.href = "/html/group/groupVolunteerSign.html?activityId=" + activityId;
    }

    function getData(groupId){
            $.ajax({
                url: '/activity/listByGroup',// 跳转到 action
                headers: {'Content-type': 'application/json;charset=UTF-8'},//传入数据数据格式 json
                data: JSON.stringify({
                    id:groupId
                }),
                type: 'post',
                cache: false,
                dataType: 'json',
                success: function (data) {
                    if (data.statusCode == 0) {
                        localStorage.setItem("OrgList", JSON.stringify(data.data));
                        for (var i = 0; i < data.data.length; i++) {
                            $("#activityList").append(listStr(data.data[i]));
                        }
                    } else {
                        alert(data.statusMessage);
                    }
                },
                error: function () {
                    // view("异常！");
                    alert("用户未登录或者服务器连接异常！");
//                    location.href = "/html/login/login.html";
                }
            });
    }

    $(
        function (){
            if (location.search.substr(1).split("=")[1] != undefined && location.search.substr(1).split("=")[1] != 0) {
                getData(location.search.substr(1).split("=")[1]);
            }
        }

    );
</script>
</html>